﻿using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using Exhibition.Dao;

using Exhibition.Service;

using Exhibition.Common.Helper;

using Exhibition.Dao.ViewModel;

namespace Exhibition.manager
{

    public partial class MessageInfoDetail : BaseAdminPage
    {

        MessageInfoModel model = new MessageInfoModel();
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {

                GetMessageInfo();
            }

        }

        private void GetMessageInfo()
        {

            model = CenterService.messageInfoService.GetOneById(reqID);
            if (model != null)
            {

                //信息名称
                txtMsgName.Value = model.MsgName.ToString();

                //信息内容
                txtMsgContent.Value = model.MsgContent.ToString();

                ////创建者
                //txtCreateUserId.Value = model.CreateUserId.ToString();

                ////创建时间
                //txtCreateTime.Value = model.CreateTime.ToString();

                //接收用户
                txtGetUserId.Value = model.GetUserId.ToString();

                //
                txtUserType.Value = model.UserType.ToString();

            }

        }

        /// <summary>
        /// 保存一条数据
        /// <summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {

            model = string.IsNullOrEmpty(hfId.Value) ? new MessageInfoModel() : CenterService.messageInfoService.GetOneById(Convert.ToInt32(hfId.Value));
            //信息名称
            model.MsgName = txtMsgName.Value;

            //信息内容
            model.MsgContent = txtMsgContent.Value;

            //创建者
            model.CreateUserId = AdminUser.Id;

            //创建时间
            model.CreateTime = DateTime.Now;

            //接收用户
            model.GetUserId = txtGetUserId.Value;

            //
            model.UserType = Convert.ToInt32(txtUserType.Value);

            if (CenterService.messageInfoService.Save(model) > 0)
            {


                JsHelper.Unblock(this, CommFunMsg.GetMessage("A0001", Lan.zh));
            }
            else
            {
                JsHelper.Alert(this, CommFunMsg.GetMessage("E0001", Lan.zh));
            }
        }

    }

}

